package com.kensure.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import co.kensure.mem.NumberUtils;

import com.kensure.shike.baobei.model.SKBaobei;
import com.kensure.shike.baobei.model.SKType;
import com.kensure.shike.baobei.service.SKBaobeiService;
import com.kensure.shike.baobei.service.SKTypeService;
import com.kensure.shike.order.model.SKOrder;
import com.kensure.shike.order.model.SKOrderBack;
import com.kensure.shike.order.service.SKOrderBackService;
import com.kensure.shike.order.service.SKOrderService;

/**
 * 关于页面跳转的页面跳转
 * 
 * @author fankaidi
 *
 */
@Controller
@RequestMapping(value = "gl")
public class GuanLiPageController {

	@Resource
	private SKBaobeiService sKBaobeiService;
	@Resource
	private SKTypeService sKTypeService;
	@Resource
	private SKOrderService sKOrderService;
	@Resource
	private SKOrderBackService sKOrderBackService;
	

	// 首页
	@RequestMapping("index")
	public String index(HttpServletRequest req, HttpServletResponse rep, Model model) {
		return "page1/houtai/index.jsp";
	}
	
	// 商品列表
	@RequestMapping("bblist")
	public String bblist(HttpServletRequest req, HttpServletResponse rep, Model model) {
		return "page1/houtai/bblist.jsp";
	}


	// 登录页面
	@RequestMapping("login")
	public String login(HttpServletRequest req, HttpServletResponse rep, Model model) {
		return "page1/houtai/login.jsp";
	}

	// 会员列表
	@RequestMapping("userlist")
	public String userlist(HttpServletRequest req, HttpServletResponse rep, Model model) {
		return "page1/houtai/userlist.jsp";
	}

	// 订单列表
	@RequestMapping("orderlist")
	public String orderlist(HttpServletRequest req, HttpServletResponse rep, Model model) {
		return "page1/houtai/orderlist.jsp";
	}

	// 退货详情
	@RequestMapping("tuihuo")
	public String tuihuo(HttpServletRequest req, HttpServletResponse rep, Model model) {
		String id = req.getParameter("id");
		if (StringUtils.isNotBlank(id)) {
			SKOrder order = sKOrderService.detail(NumberUtils.parseLong(id, null));
			List<SKOrderBack> list = sKOrderBackService.getList(NumberUtils.parseLong(id, null));
			req.setAttribute("order", order);
			req.setAttribute("list", list);
		}
		return "page1/houtai/tuihuo.jsp";
	}
}
